/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */

/**
 * @version mempool.h 0.0.1
 * @package Comoro
 * @author Dr.NP <np@bsgroup.org>
 * 
 * Center server memory pool header
 */

// Constants
#define MAX_CLIENT_EXTENDS					1024
#define MAX_GROUP_EXTENDS					64
#define MAX_ROOM_EXTENDS						64
#define MAX_CLIENT_GROUPS					16
#define MAX_USERNAME_LENGTH					64

#define BASE_POOL_SIZE						1024

struct client_item
{
	int client_id;
	
	// User detail
	unsigned long long user_id;
	char user_name[MAX_USERNAME_LENGTH];
	
	int curr_runner_id;
	int curr_room_id;
	int curr_group_id;
	
	// Other informations
	unsigned long login_time;
	int in_groups[MAX_CLIENT_GROUPS];
	
	// Big integer pool, all extends stored here
	unsigned long long extends_pool[MAX_CLIENT_EXTENDS];
};

struct group_item
{
	int group_id;
	
	// Group detail
	char group_name[MAX_USERNAME_LENGTH];
	
	int curr_runner_id;
	int curr_room_id;
	
	// Password
	char password[MAX_USERNAME_LENGTH];

	// Big integer pool, extends params stored here
	unsigned long long extends_pool[MAX_GROUP_EXTENDS];
};

struct room_item
{
	int room_id;
	
	// Room detail
	char room_name[MAX_USERNAME_LENGTH];
	
	int curr_runner_id;
	
	// Big integer pool, extends params stored here
	unsigned long long extends_pool[MAX_ROOM_EXTENDS];
};

/* BEGIN OF FUNCTION DEFINE */
int mempool_init									();

int mempool_add_client							(int, unsigned long long, char *);
int mempool_set_client_runner					(int, int);
int mempool_set_client_room						(int, int);
int mempool_set_client_group					(int, int);
int mempool_set_client_uid						(int, unsigned long long);
int mempool_set_client_uname					(int, char *);
int mempool_set_client_extends					(int, int, unsigned long long);
int mempool_get_client_runner					(int);
int mempool_get_client_room						(int);
int mempool_get_client_group					(int);
unsigned long long mempool_get_client_uid		(int);
char * mempool_get_client_uname					(int);
unsigned long long mempool_get_client_extends   (int, int);
int mempool_add_client_group					(int, int);
int mempool_del_client_group					(int, int);
int mempool_del_client							(int);

int mempool_add_group							(char *, char *);
int * mempool_list_group_client					(int, int *);
int mempool_set_group_runner					(int, int);
int mempool_set_group_room						(int, int);
int mempool_get_group_runner					(int);
int mempool_get_group_room						(int);
int mempool_del_group							(int);
unsigned long long mempool_get_group_pool		(int, int);
int mempool_set_group_pool						(int, int, unsigned long long);

int mempool_add_room								(char *);
int mempool_set_room_runner						(int, int);
int mempool_del_room								(int);
unsigned long long mempool_get_room_pool		(int, int);
int mempool_set_room_pool						(int, int, unsigned long long);

int mempool_count_client							();
int mempool_count_group							();
int mempool_count_room							();
int mempool_count_base_client					(int);

struct client_item * mempool_cpool				();
int mempool_cpool_size							();
struct group_item * mempool_gpool				();
int mempool_gpool_size							();
/* END OF FUNCTION DEFINE */
